<?php

namespace BoxShadow\UsersBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UsersType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('username','text')
            ->add('email','repeated',array(
                'type' => 'email',
                'invalid_message' => 'The email fields must match',
                'first_options' => array('label' => 'Email'),
                'second_options' => array('label' => 'Repeat email')
            ))
            ->add('password','repeated',array(
                'type' => 'password',
                'invalid_message' => 'The password fields must match.',
                'first_options'  => array('label' => 'Password'),
                'second_options' => array('label' => 'Repeat password'),
            ))
            ->add('surname','text')
            ->add('birth','date',array(
                'widget' => 'choice'
            ))
            ->add('gender','choice',array(
                'choices'   => array('m' => 'Male', 'f' => 'Female'),
                'expanded' => TRUE,
                'multiple' => FALSE
            ))
            ->add('first_name','text')

        ;
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'BoxShadow\UsersBundle\Entity\Users'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'boxshadow_usersbundle_users';
    }
}
